package main.Q1601_1700;

import java.util.LinkedList;
import java.util.Queue;

public class Q1691_1700 {
	public static void main(String[] args) {
		System.out.println("Question1691：");
		System.out.println("Question1692：");
		System.out.println("Question1693：");
		System.out.println("Question1694：");
		System.out.println("Question1695：");
		System.out.println("Question1696：");
		System.out.println("Question1697：");
		System.out.println("Question1698：");
		System.out.println("Question1699：");
		System.out.println("Question1700：无法吃午餐的学生数量");
	}
}

class Question1700 {
	public int countStudents(int[] students, int[] sandwiches) {
		Queue<Integer> queue = new LinkedList<>();
		int cycCount = 0;//学生轮转人数
		int index = 0;//三明治下标
		for (Integer student : students) queue.add(student);//
		while (!queue.isEmpty() && cycCount <= queue.size()) {
			if (queue.peek() == sandwiches[index]) {
				queue.poll();
				index++;
				cycCount = 0;
			} else {
				queue.add(queue.poll());//入队尾
				cycCount++;
			}
		}
		return queue.size();
	}
}